#include "LinkTree.h"
#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
int InitLTree(LTree *tree)
{
    tree->root=NULL;
    return true;
}

TreeNode *CreateTreeNode(ElementType element)
{
    TreeNode *treenode=(TreeNode*)malloc(sizeof(TreeNode));
    if(treenode==NULL)
    {
        printf("craete malloc erroe\n");
        return NULL;
    }
    treenode->data=element;
    treenode->left=NULL;
    treenode->right=NULL;
    treenode->parent=NULL;
    return treenode;
}
TreeNode *FindBrother(TreeNode *treenode)
{
    if(treenode->parent==NULL)
    {
        return NULL;
    }
    TreeNode *parent=treenode->parent;
    if(parent->left==NULL)
    {
        return parent->left;
    }
    else
    {
        return parent->right;
    }
}
void InsertNode(TreeNode *node,ElementType element)
{
    TreeNode *brother=FindBrother(node);
    if(brother!=NULL)
    {
        
    }
    if(node->left==NULL)
    {
        node->left=CreateTreeNode(element);
        return ;
    }
    if(node->right==NULL)
    {
        node->right=CreateTreeNode(element);
        return;
    }
}
TreeNode *FindIndexParent(LTree *tree)
{
    if(tree->root==NULL)
    {
        return NULL;
    }
    if(tree->root->left==NULL)
    {
        return tree->root;
    }
    else if(tree->root->right==NULL)
    {
        return tree->root;
    }
}
void InsertTreeData(LTree *tree, ElementType element)
{
       
}
